<?php
/* 
* @Author: LDF QQ 47121862
* @Date:   2014-05-19 21:22:39
* @Last Modified by:   LDF QQ 47121862
* @Last Modified time: 2014-06-04 10:00:19
*/
Class BrandControl extends AuthControl{
	public $model;
	public function __auto(){
		$this->model = K('Brand');
	}
	//品牌列表
	public function index(){
		$total=$this->model->count();
		$page=new page($total);
		$this->data = $this->model->limit($page->limit())->all();
		$this->page=$page->show();
		$this->display();
	}
	//添加品牌
	public function add(){
		if(IS_POST){
			if($this->model->addBrand()){
				$this->success('添加品牌成功...');
			}else{
				$this->error($this->model->error);
			}
		}else{
			$this->cate=cache('categoryCache');
			$this->display();
		}
	}
	//修改品牌
	public function edit(){
		if(IS_POST){
			if($this->model->editBrand()){
				$this->success('修改品牌成功。。。');
			}else{	
				$this->error($this->model->error);
			}
		}else{
			$bid = Q('bid',0,'intval');
			$bdata = $this->model->where('bid='.$bid)->find();
			$this->field=$bdata;
			$this->cate=cache('categoryCache');
			$this->display();
		}
	}
	//删除品牌
	public function del(){
		if($this->model->delBrand()){
			$this->success('删除品牌成功...');
		}else{
			$this->error($this->model->error);
		}
	}
	//更新缓存
	public function updateCache(){
		if($this->model->updateCache()){
			$this->success('更新缓存成功');
		}
	}
}
